package org.liaohailong.victorlibrary.ui.slide;

import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import org.liaohailong.victorlibrary.R;

/**
 * Author: liaohailong
 * Date: 2023/3/13
 * Time: 19:39
 * Description:
 **/
public class SlideFragment extends Fragment {
    private static final String TAG = "SlideFragment";
    private void log(@NonNull String msg, Object... args) {
        Log.i(TAG, String.format(msg, args));
    }

    private static final int sColors[] = new int[]{
            Color.parseColor("#FF56FF"),
            Color.parseColor("#445666"),
    };
    private final int index;

    public SlideFragment(int index) {
        this.index = index;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater,
                             @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.frag_slide, container, false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        view.setBackgroundColor(sColors[index % sColors.length]);

        view.findViewById(R.id.fl_content).setOnClickListener(v -> {
            log("fl_content onclick");
        });

        view.findViewById(R.id.fl_menu).setOnClickListener(v -> {
            log("fl_menu onclick");
        });
    }
}
